package com.yida.gwj.expend.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.yida.gwj.expend.domain.GwjMaintenanceFundsBusinessInfo;
import com.yida.gwj.expend.enums.FlagStatusEnum;
import com.yida.gwj.expend.mapper.GwjMaintenanceFundsBusinessInfoMapper;
import com.yida.gwj.expend.service.IGwjMaintenanceFundsBusinessInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 维修资金使用申请工程信息Service业务层处理
 *
 * @author lgp
 * @date 2023-02-20
 */
@Service
public class GwjMaintenanceFundsBusinessInfoServiceImpl implements IGwjMaintenanceFundsBusinessInfoService {
    @Autowired
    private GwjMaintenanceFundsBusinessInfoMapper gwjMaintenanceFundsBusinessInfoMapper;

    /**
     * 查询维修资金使用申请工程信息
     *
     * @param businessInfoId 维修资金使用申请工程信息主键
     * @return 维修资金使用申请工程信息
     */
    @Override
    public GwjMaintenanceFundsBusinessInfo selectGwjMaintenanceFundsBusinessInfoByBusinessInfoId(Long businessInfoId) {
        return gwjMaintenanceFundsBusinessInfoMapper.selectGwjMaintenanceFundsBusinessInfoByBusinessInfoId(businessInfoId);
    }

    /**
     * 查询维修资金使用申请工程信息列表
     *
     * @param gwjMaintenanceFundsBusinessInfo 维修资金使用申请工程信息
     * @return 维修资金使用申请工程信息
     */
    @Override
    public List<GwjMaintenanceFundsBusinessInfo> selectGwjMaintenanceFundsBusinessInfoList(GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo) {
        return gwjMaintenanceFundsBusinessInfoMapper.selectGwjMaintenanceFundsBusinessInfoList(gwjMaintenanceFundsBusinessInfo);
    }

    /**
     * 新增维修资金使用申请工程信息
     *
     * @param gwjMaintenanceFundsBusinessInfo 维修资金使用申请工程信息
     * @return 结果
     */
    // @CachePut(value = "gwj_intranet:maintenance_funds_business_info", key = "#gwjMaintenanceFundsBusinessInfo.businessId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusinessInfo insertGwjMaintenanceFundsBusinessInfo(GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo) {
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessInfoMapper.insertGwjMaintenanceFundsBusinessInfo(gwjMaintenanceFundsBusinessInfo), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessInfoMapper.selectGwjMaintenanceFundsBusinessInfoByBusinessId(gwjMaintenanceFundsBusinessInfo.getBizId());
    }

    /**
     * 修改维修资金使用申请工程信息
     *
     * @param gwjMaintenanceFundsBusinessInfo 维修资金使用申请工程信息
     * @return 结果
     */
    // @CachePut(value = "gwj_intranet:maintenance_funds_business_info", key = "#gwjMaintenanceFundsBusinessInfo.businessId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusinessInfo updateGwjMaintenanceFundsBusinessInfo(GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo) {
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessInfoMapper.updateGwjMaintenanceFundsBusinessInfo(gwjMaintenanceFundsBusinessInfo), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessInfoMapper.selectGwjMaintenanceFundsBusinessInfoByBusinessId(gwjMaintenanceFundsBusinessInfo.getBizId());
    }

    /**
     * 删除维修资金使用申请工程信息信息-通过业务ID
     *
     * @param businessId 维修资金使用申请工程信息主键
     * @return 结果
     */
   // @CacheEvict(value = "gwj_intranet:maintenance_funds_business_info", key = "#businessId", condition = "#result == 1")
    @Override
    public int deleteGwjMaintenanceFundsBusinessInfoByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessInfoMapper.deleteGwjMaintenanceFundsBusinessInfoByBusinessId(businessId);
    }

    @Override
    public GwjMaintenanceFundsBusinessInfo selectGwjMaintenanceFundsBusinessInfoByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessInfoMapper.selectGwjMaintenanceFundsBusinessInfoByBusinessId(businessId);
    }


}
